package com.lovecanon.jzjl.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.concurrent.TimeUnit;

@Repository
public class RedisService {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    public void set(String key,String value){
        stringRedisTemplate.opsForValue().set(key,value);
    }
    public String get(String key){
        String s = stringRedisTemplate.opsForValue().get(key);
        return s;
    }

    public void  set (String key, String value, long timeout){
        stringRedisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
    }

}
